package com.example.student.mapper;


import com.example.student.pojo.Score;
import com.example.student.pojo.Stu;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 部门管理
 */
@Mapper
public interface ScoreMapper {

    @Select("select * from student_scores")
    List<Score> list();

    @Delete("delete from student_scores where student_number = #{id}")
    void deleteById(Integer id);

    @Select("select * from student_scores where student_number = #{id}")
    Score getByID(Integer id);

    @Update("update student_scores set name = #{name},chinese=#{chinese},math=#{math},english =#{english},java=#{java},sports=#{sports},update_time = #{updateTime},total=#{total} where student_number = #{studentNumber}")
    void update(Score score);


    @Select("select count(*) from student_scores")
    public long count();

    @Select("select * from student_scores order by student_number limit #{start},#{pageSize}")
    List<Score> page(Integer start,Integer pageSize);

    @Insert("insert into student_scores(student_number,name,chinese,math,english,java,sports,create_time,update_time) " +
            "values(#{studentNumber},#{name},#{chinese},#{math},#{english},#{java},#{sports},#{createTime},#{updateTime})")
    void insert(Score score);

    long counts(Integer studentId, String name);

    List<Score> pages(Integer start, Integer pageSize, Integer studentId, String name);

    @Select("select count(*) " +
            "from student_scores " +
            "join students on student_scores.student_number = students.student_id " +
            "WHERE students.dept_id = #{deptId}")
    long classCounts(Integer deptId);



    @Select("select student_scores.* " +
            "from student_scores " +
            "join students on student_scores.student_number = students.student_id " +
            "where students.dept_id = #{deptId} " +
            "limit #{start}, #{pageSize}")
    List<Score> classPages(Integer start,Integer pageSize,Integer deptId);

    @Select("select * from student_scores order by total desc limit #{start},#{pageSize}")
    List<Score> rankPage(Integer start, Integer pageSize);
}
